#!/usr/bin/env python
#-*- coding: utf-8 -*-
from flask.ext.babel import Babel


class FlaskBabel(Babel):

    def __init__(self, app=None):
        super(FlaskBabel, self).__init__()
        if app is not None:
            self.init_app(app)

    def init_app(self, app):
        if not hasattr(app, 'extensions'):
            app.extensions = dict()
        if 'babel' in app.extensions:
            raise ValueError('Already registered extension Babel.')
        super(FlaskBabel, self).init_app(app)
        app.extensions['babel'] = self


official_babel = FlaskBabel()
